#if SERVER
using ActorSystem;
using Example2;
using Net.Entities;
using Net.Share;

namespace Example2
{
    public partial class Bullet : ActorBase
    {
        internal Actor target;
        public float moveSpeed = 15f;

        public override void OnUpdate()
        {
            transform.Translate(0, 0, moveSpeed * Time.deltaTime);

        }

        public override void OnOperation(in Operation opt)
        {
            switch (opt.cmd)
            {
                case Command.Damage:
                    Damage(opt);
                    break;
                default:
                    base.OnOperation(opt);
                    break;
            }
        }

        private void Damage(in Operation opt)
        {
            if (Scene.TryGetActor<Actor>(opt.target, out var actor))
            {
                if (actor == null)
                    return;
                actor.Damage(target, new DamageBuff() { Damage = 20 });
            }
        }
    }
}
#endif